﻿<phone:PhoneApplicationPage 
    x:Class="Wulong.Phone.Dianping.Views.MainView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:cal="http://www.caliburnproject.org" mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True"
    Style="{StaticResource TransitionPageStyle}">
    
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <controls:Panorama 
            x:Name="pano"
            Title="{Binding Path=Appi18n.App_Title, Source={StaticResource ls}}"
            SelectionChanged="Panorama_SelectionChanged">
            <controls:Panorama.Background>
                <ImageBrush ImageSource="/Images/PanoBackground.png"/>
            </controls:Panorama.Background>
            <controls:PanoramaItem>
                <controls:PanoramaItem.HeaderTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Path=Appi18n.Categories, Source={StaticResource ls}}"/>
                            <StackPanel>
                                <Button cal:Message.Attach="[Event Click]=[Action SetMyCity]"
                                        Style="{StaticResource NoBorderBtnStyle}"
                                        Margin="0"
                                        Padding="0"
                                        VerticalAlignment="Bottom">
                                    <StackPanel>
                                        <Image Source="/Images/BtnLocation.png"
                                               Margin="0"/>
                                        <TextBlock FontSize="16"
                                           VerticalAlignment="Top"
                                           HorizontalAlignment="Center"
                                           Margin="0"
                                           Padding="0"
                                           Text="{Binding Path=Appi18n.ChangeCity, Source={StaticResource ls}}"/>
                                    </StackPanel>
                                </Button>
                            </StackPanel>
                        </StackPanel>
                    </DataTemplate>
                </controls:PanoramaItem.HeaderTemplate>
                <Grid Margin="0,0,0,48">
                <ListBox Style="{StaticResource ListStyle}" 
                         x:Name="ChannelList" 
                         SelectedItem="{Binding SelectedChannel, Mode=TwoWay}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Button cal:Message.Attach="[Event Click]=[Action ViewChannel($this)]"
                                    Style="{StaticResource ListItemBtnStyle}"> 
                                <StackPanel Orientation="Horizontal" Width="380">
                                    <Image Source="{Binding ImageUrl}"
                                           Margin="0,12,12,0"
                                           HorizontalAlignment="Left"/>
                                    <TextBlock Text="{Binding Name}" 
                                               Style="{StaticResource PhoneTextLargeStyle}"
                                               VerticalAlignment="Center"
                                               HorizontalAlignment="Left"/>
                                </StackPanel>
                            </Button>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
                </Grid>
            </controls:PanoramaItem>
            <controls:PanoramaItem
                Orientation="Horizontal">
                <controls:PanoramaItem.HeaderTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Path=Appi18n.GroupOn, Source={StaticResource ls}}"/>
                            <Button cal:Message.Attach="[Event Click]=[Action RefreshGroupOnList]"
                                    Style="{StaticResource NoBorderBtnStyle}"
                                    Margin="0 0 0 0"
                                    Padding="0">
                                <StackPanel>
                                    <Image Source="/Images/BtnRefresh.png"
                                       Margin="0 0 0 0"/>
                                    <TextBlock Text="{Binding Path=Appi18n.Btn_Refresh, Source={StaticResource ls}}"
                                               FontSize="16"
                                               HorizontalAlignment="Center"/>
                                </StackPanel>
                            </Button>
                            <Button cal:Message.Attach="[Event Click]=[Action ViewGroupOnList]"
                                    Style="{StaticResource NoBorderBtnStyle}"
                                    Margin="0 0 0 0"
                                    Padding="0">
                                <StackPanel>
                                    <Image Source="/Images/Btn_List.png"
                                       Margin="0 0 0 0"/>
                                    <TextBlock Text="{Binding Path=Appi18n.LoadMore, Source={StaticResource ls}}"
                                               FontSize="16"
                                               HorizontalAlignment="Center"/>
                                </StackPanel>
                            </Button>
                        </StackPanel>
                    </DataTemplate>
                </controls:PanoramaItem.HeaderTemplate>
                <ItemsControl x:Name="GroupOnList">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <toolkit:HubTile 
                                cal:Message.Attach="[Event Tap]=[Action ViewGroupOn($dataContext)]"
                                Margin="12,12,0,0"
                                Source="{Binding ImageUrl}"
                                Title="{Binding Price}"
                                Message="{Binding Desc}"
                                Notification="{Binding ItemsSoldDesc}"
                                DisplayNotification="True"
                                GroupTag="groupon"
                                />
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <toolkit:WrapPanel Orientation="Vertical" />
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                </ItemsControl>
            </controls:PanoramaItem>
            <controls:PanoramaItem>
                <controls:PanoramaItem.HeaderTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Path=Appi18n.Coupons, Source={StaticResource ls}}"/>
                            <Button cal:Message.Attach="[Event Click]=[Action RefreshHotPromoList]" 
                                    Style="{StaticResource NoBorderBtnStyle}"
                                    Margin="0 0 0 0"
                                    Padding="0">
                                <StackPanel>
                                    <Image Source="/Images/BtnRefresh.png" 
                                       Margin="0 0 0 0"/>
                                    <TextBlock Text="{Binding Path=Appi18n.Btn_Refresh, Source={StaticResource ls}}"
                                               FontSize="16"
                                               HorizontalAlignment="Center"/>
                                </StackPanel>
                            </Button>
                            <Button cal:Message.Attach="[Event Click]=[Action ViewPromotionList]"
                                    Style="{StaticResource NoBorderBtnStyle}"
                                    Margin="0 0 0 0"
                                    Padding="0">
                                <StackPanel>
                                    <Image Source="/Images/Btn_List.png" 
                                       Margin="0 0 0 0"/>
                                    <TextBlock Text="{Binding Path=Appi18n.LoadMore, Source={StaticResource ls}}"
                                               FontSize="16"
                                               HorizontalAlignment="Center"/>
                                </StackPanel>
                            </Button>
                        </StackPanel>
                    </DataTemplate>
                </controls:PanoramaItem.HeaderTemplate>
                <ListBox x:Name="HotPromotionList" SelectedItem="{Binding SelectedPromo}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Button cal:Message.Attach="[Event Click]=[Action ViewPromotion($dataContext)]"
                                    Style="{StaticResource ListItemBtnStyle}">
                                <StackPanel Orientation="Horizontal" Width="400">
                                    <Image Source="{Binding ImageUrl}"
                                           Margin="12,0"
                                           HorizontalAlignment="Left"/>
                                    <StackPanel>
                                        <TextBlock Text="{Binding Title}" 
                                                   TextWrapping="Wrap" 
                                                   Foreground="Brown"
                                                   Width="200"
                                                   Style="{StaticResource PhoneTextLargeStyle}"/>
                                        <TextBlock Text="{Binding SubTitle}"
                                                   Width="200"
                                                   TextWrapping="Wrap" 
                                                   Style="{StaticResource PhoneTextNormalStyle}"/>
                                    </StackPanel>
                                </StackPanel>
                            </Button>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </controls:PanoramaItem>
        </controls:Panorama>
    </Grid>
    <shell:SystemTray.ProgressIndicator>
        <shell:ProgressIndicator 
            IsIndeterminate="{Binding IsBusy}" 
            IsVisible="{Binding IsBusy}"
            Text="{Binding Path=Appi18n.Loading, Source={StaticResource ls}}"/>
    </shell:SystemTray.ProgressIndicator>
</phone:PhoneApplicationPage>